package mydesign.chapters01.v2;


import mydesign.chapters01.v2.flybehavior.FlyBehavior;
import mydesign.chapters01.v2.quackbehavior.QuackBehavior;

public abstract   class Duck  {

    FlyBehavior flyBehavior;

    QuackBehavior quackBehavior;

    public abstract void display();

    public void performFly(){
        flyBehavior.fly();
    }

    public void performQuack(){
        quackBehavior.quack();
    }

    public void swim(){
        System.out.printf("所有鸭子都会游泳");
    }


    public FlyBehavior getFlyBehavior() {
        return flyBehavior;
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public QuackBehavior getQuackBehavior() {
        return quackBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }
}
